home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / INTMATH.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  49 lines

  1.                                          (* Chapter 3 - Program 2 *)
  2. MODULE IntMath;
  3.  
  4. FROM InOut IMPORT WriteLn, WriteString, WriteInt;
  5.  
  6. VAR IntSum, IntDif, IntMul, IntDiv, IntRem : INTEGER;
  7.     A, B                                   : INTEGER;
  8.  
  9. BEGIN
  10.    A := 9;             (* Simple assignment                  *)
  11.    B := A + 4;         (* Addition                           *)
  12.    IntSum := A + B;    (* Addition                           *)
  13.    IntDif := A - B;    (* Subtraction                        *)
  14.    IntMul := A * B;    (* Multiplication                     *)
  15.    IntDiv := B DIV A;  (* Integer division, the result is a
  16.                           truncated integer number.          *)
  17.    IntRem := B MOD A;  (* d is the remainder of the integer
  18.                           division.                          *)
  19.    A := (A + B) DIV (3*B + 7);  (* Composite math statement  *)
  20.  
  21.    WriteString("The integer values are ");
  22.    WriteInt(IntSum,6);
  23.    WriteInt(IntDif,6);
  24.    WriteInt(IntMul,6);
  25.    WriteInt(IntDiv,6);
  26.    WriteInt(IntRem,6);
  27.    WriteLn;
  28.  
  29.    INC(A);       (* This increments the value of A   *)
  30.    DEC(A);       (* This decrements the value of A   *)
  31.    INC(A,3);     (* This adds 3 to the value of A    *)
  32.    DEC(A,7);     (* This reduces the value of A by 7 *)
  33.    INC(A,B*2+4); (* A composite incrementing amount  *)
  34.  
  35.    A := MIN(INTEGER);  (* This produces the smallest INTEGER *)
  36.    B := MAX(INTEGER);  (* This produces the largest INTEGER  *)
  37.  
  38. END IntMath.
  39.  
  40.  
  41.  
  42.  
  43. (* Result of execution
  44.  
  45. The integer values are     22    -4   117     1     4
  46.  
  47. *)
  48.  
  49.